package com.hxzy.config;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.lang.annotation.Annotation;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URI;

@Component
public class CustomGlobalFilter implements GlobalFilter, Ordered {

    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("custom global filter 进入过滤器");
        ServerHttpRequest request = exchange.getRequest();
        System.out.println(request.getURI().getPath());
            return chain.filter(exchange);
    }

    public int value() {
        return 1;
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
